//
//  WSMainViewController.m
//  LANGirl
//
//  Created by 杨泓晔 on 16/3/8.
//  Copyright © 2016年 杨泓晔. All rights reserved.
//

#import "MainViewController.h"
#import "MainCell.h"
#import <AVFoundation/AVFoundation.h>
#include <sys/sysctl.h>
#import "UserTypeViewController.h"
#import "PXGafaerProtocolViewController.h"
#import "YHYDesigneViewsViewController.h"

#import "AppDelegate.h"
#import <AFNetworking.h>
#import <AFNetworkReachabilityManager.h>
#import <AFHTTPSessionManager.h>
#import <AFHTTPRequestOperation.h>
#import <AFHTTPRequestOperationManager.h>
#import "UserTypeViewController.h"
@interface MainViewController ()<UICollectionViewDataSource, UICollectionViewDelegate,UITextFieldDelegate>
{
    
    NSString *phoneNumber;
    NSString *passWord;
    NSString *yanzheng;
    UIScrollView *worldScrollView;
    UIView *myView;
    UIView *regisnView;
    UIView *loginView;
    NSTimer *scrollTimer;
    NSMutableDictionary *paramars;
    NSString *loginNumber;
    
    
}
@property (nonatomic, strong) AVPlayer *player;

@property (nonatomic, strong) UICollectionView *collectionView;

@property (nonatomic, strong) UIPageControl *pageControl;

@property (nonatomic, strong) UIButton *loginBtn;

@property (nonatomic, strong) UIButton *registBtn;

@property (nonatomic, strong) UITextField *chinalabel;

@property (nonatomic, strong) UITextField *locklabel;

@property (nonatomic, strong) UITextField *codelabel;

@property (nonatomic,strong)  UIButton *huolabel;

@property (nonatomic, strong) NSArray *titleArray;

@property (nonatomic, strong) UIImageView *icoImage;
@property (nonatomic, strong) UIImageView *icImage;
@property (nonatomic, strong) UIButton *bttn;
@property (nonatomic, strong) UILabel *henglabel;
@property (nonatomic, strong) UIImageView *touImage;
@property (nonatomic, strong)  UIButton *fourView;
@property (nonatomic, strong) UILabel *henglabel1;
@property (nonatomic, strong) UIImageView *shouImage;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIImageView *lockImage;
@property (nonatomic, strong) UIButton *seebtn;
@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *xiLabel;
@property (nonatomic, strong) UILabel *linLabel2;


@property (nonatomic, strong) UIButton *button;
@property (nonatomic, strong) UIImageView *ioImage;
@property (nonatomic, strong) UIImageView *shImage;
@property (nonatomic, strong) UITextField *chlabel;
@property (nonatomic, strong) UILabel *rank;
@property (nonatomic, strong) UIImageView *lckImage;
@property (nonatomic, strong) UITextField *lcklabel;
@property (nonatomic, strong) UIButton *see;
@property (nonatomic, strong) UILabel *rank1;
@property (nonatomic, strong) UIImageView *phoneImage;
@property (nonatomic, strong) UILabel *rank2;
@property (nonatomic, strong) UILabel *longLabel;
@property (nonatomic, strong) UILabel *yuLabel;
@property (nonatomic, strong) UILabel *lineLabel;
@property (nonatomic, strong) UIButton *fouView;
@property (nonatomic, strong) UILabel *xieLabel;
@property (nonatomic, strong) UILabel *lineLabel2;

@property (assign, nonatomic) NSInteger timeNum;
@property (strong, nonatomic) NSTimer *getTime;
@property (nonatomic, assign) BOOL isNo;

@end


@implementation MainViewController

- (void)dealloc{
    
    self.view.backgroundColor = [UIColor blackColor];
    [self removeNotification];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [_player play];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    
}


- (void)viewDidDisappear:(BOOL)animated {
    
    [_player pause];
    [scrollTimer setFireDate:[NSDate distantFuture]];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    paramars = [NSMutableDictionary new];
    self.view.userInteractionEnabled=YES;
    UITapGestureRecognizer *usertap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(userAction:)];
    [self.view addGestureRecognizer:usertap];
    
    _titleArray=@[@"随时随地发布设计任务",@"保护隐私 在线交流 不必担心被骚扰",@"帮助您找到更满意的设计师",@"为您提供高端更私人的装修设计方案"];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    //self.navigationController.navigationBar.barTintColor = MAINCOLOR;
    
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"家范儿" ofType:@"mp4"];
    NSURL *sourceMovieURL = [NSURL fileURLWithPath:filePath];
    
    AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:sourceMovieURL options:nil];
    AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
    self.player = [AVPlayer playerWithPlayerItem:playerItem];
    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    playerLayer.frame = [UIScreen mainScreen].bounds;
    NSLog(@"%@", NSStringFromCGRect(playerLayer.frame));
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
    
    [self.view.layer addSublayer:playerLayer];
    NSLog(@"%@", NSStringFromCGRect(self.view.layer.frame));
    [self.player play];
    
    myView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    [self.view addSubview:myView];
    myView.backgroundColor = [UIColor clearColor];
    
    
    
    
    
    
    
    
    [self addNotification];
    
    //    [self createMainView];
    //    [self creatLogIn];
    [self createLoginBtn];
    [self createRegistBtn];
    [self createPageControl];
    [self createIcoImage];
    [self addWorldScrollView];
    
    
}

//添加 文字 滑动 试图
-(void)addWorldScrollView{
    worldScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, KScreenHeight-140, KScreenWidth, 30)];
    [myView addSubview:worldScrollView];
    worldScrollView.contentSize = CGSizeMake(KScreenWidth * _titleArray.count, 0);
    scrollTimer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(timer:) userInfo:nil repeats:YES];
    for (int i = 0; i < _titleArray.count; i ++) {
        UILabel *wordLabe = [UILabel new];
        [worldScrollView addSubview:wordLabe];
        wordLabe.textAlignment = NSTextAlignmentCenter;
        wordLabe.backgroundColor = [UIColor clearColor];
        wordLabe.tag = 1000 + i;
        wordLabe.frame = CGRectMake(KScreenWidth * i, 0, KScreenWidth, worldScrollView.frame.size.height);
        wordLabe.text = _titleArray[i];
        wordLabe.textColor = [UIColor whiteColor];
        
    }
    worldScrollView.pagingEnabled = YES;
    worldScrollView.showsHorizontalScrollIndicator = NO;
    worldScrollView.backgroundColor = [UIColor clearColor];
    
    
    
}
- (void)createPageControl {
    
    self.pageControl = [[UIPageControl alloc] init];
    self.pageControl.numberOfPages = _titleArray.count;
    //    [self.pageControl addTarget:self action:@selector(pageControlAction:) forControlEvents:UIControlEventValueChanged];
    [myView addSubview:_pageControl];
    [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 15));
        make.top.equalTo(self.loginBtn).offset(-30);
        make.left.mas_equalTo(0);
    }];
    
}

//- (void)pageControlAction:(UIPageControl *)pageControl {
//
//    [self.collectionView setContentOffset:CGPointMake(SCREEN_WIDTH * pageControl.currentPage, 0) animated:YES];
//
//}
-(void)timer:(NSTimer *)timer{
    //    NSLog(@"ooooo=%f",worldScrollView.contentOffset.x);
    
    
    worldScrollView.contentOffset = CGPointMake(worldScrollView.contentOffset.x +KScreenWidth, 0);
    if (worldScrollView.contentOffset.x == KScreenWidth * 4) {
        worldScrollView.contentOffset = CGPointMake(0, 0);
    }
    self.pageControl.currentPage = worldScrollView.contentOffset.x/KScreenWidth;
    
}
- (void)createMainView {
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 20);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds collectionViewLayout:flowLayout];
    self.collectionView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_collectionView];
    
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.pagingEnabled = YES;
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    [self.collectionView registerClass:[MainCell class] forCellWithReuseIdentifier:@"cell"];
    
    
}




//  添加 注册 按钮
- (void)createRegistBtn {
    
    self.registBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [myView addSubview:_registBtn];
    [self.registBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH / 5 * 2, 50 * AUTO_WIDTH));
        make.bottom.mas_equalTo(-20);
        make.left.mas_equalTo(20);
    }];
    
    self.registBtn.backgroundColor = [UIColor blackColor];
    [self.registBtn setTitle:@"注册" forState:UIControlStateNormal];
    [self.registBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.registBtn.alpha = 0.5;
    self.registBtn.layer.cornerRadius = 3;
    self.registBtn.layer.masksToBounds = YES;
    [self.registBtn addTarget:self action:@selector(registAction:) forControlEvents:UIControlEventTouchUpInside];
}
// 添加 登陆 按钮
- (void)createLoginBtn {
    
    
    self.loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [myView addSubview:_loginBtn];
    [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH / 5 * 2, 50 * AUTO_WIDTH));
        make.bottom.mas_equalTo(-20);
        make.right.mas_equalTo(-20);
    }];
    
    self.loginBtn.backgroundColor = [UIColor whiteColor];
    [self.loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [self.loginBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.loginBtn.alpha = 0.5;
    self.loginBtn.layer.cornerRadius = 3;
    self.loginBtn.layer.masksToBounds = YES;
    [self.loginBtn addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
}
// 家范儿 logo
- (void)createIcoImage {
    
    self.icoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fan"]];
    [myView addSubview:_icoImage];
    self.icoImage.userInteractionEnabled = YES;
    [self.icoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(myView).offset(-SCREEN_HEIGHT / 10);
        make.centerX.equalTo(myView);
        make.size.mas_equalTo(CGSizeMake(350/2 *AUTO_WIDTH, 92/2 *AUTO_HEIGHT));
        
    }];
}

#pragma mark - 注册登录点击事件
//登录
- (void)loginAction {
    CATransition *transition = [CATransition animation ];
    [transition setType:@"rippleEffect"];
    [transition setDuration:1];
    [transition setRepeatCount:1];
    [self.view.layer addAnimation:transition forKey:@"transition"];
    loginView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    [myView removeFromSuperview];
    [self.view addSubview:loginView];
    
    //左侧按钮
    _bttn=[UIButton buttonWithType:UIButtonTypeCustom];
    [_bttn setImage:[UIImage imageNamed:@"fahui"] forState:UIControlStateNormal];
    [_bttn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [loginView addSubview:_bttn];
    [_bttn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(loginView.mas_top).offset(51/2 *AUTO_HEIGHT);
        make.left.equalTo(loginView).offset(20/2 *AUTO_WIDTH);
    }];
    
    
    self.icoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fan"]];
    [loginView addSubview:_icoImage];
    self.icoImage.userInteractionEnabled = YES;
    [self.icoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.top.mas_equalTo(loginView).offset(260/2 *AUTO_HEIGHT);
        make.centerX.equalTo(loginView);
        make.size.mas_equalTo(CGSizeMake(350/2 *AUTO_WIDTH, 92/2 *AUTO_HEIGHT));
        
    }];
    
    
    //横线
    _henglabel=[[UILabel alloc]init];
    _henglabel.backgroundColor=[UIColor whiteColor];
    _henglabel.alpha=0.6;
    [loginView addSubview:_henglabel];
    [_henglabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_icoImage.mas_bottom).offset(326/4 *AUTO_HEIGHT);
        make.left.mas_equalTo(loginView);
        make.height.mas_equalTo(1 *AUTO_HEIGHT);
        make.width.mas_equalTo(loginView.frame.size.width/2 -40 *AUTO_WIDTH);
    }];
    
    //头像
    _touImage=[[UIImageView alloc]init];
    _touImage.image=[UIImage imageNamed:@"llog"];
    [loginView addSubview:_touImage];
    [_touImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_icoImage.mas_bottom).offset(200/4*AUTO_HEIGHT);
        make.left.equalTo(_henglabel.mas_right).offset(0);
        make.size.mas_equalTo(CGSizeMake(128/2 *AUTO_WIDTH, 128 /2 *AUTO_HEIGHT));
        
    }];
    
    //横线
    _henglabel1=[[UILabel alloc]init];
    _henglabel1.backgroundColor=[UIColor whiteColor];
    _henglabel1.alpha=0.6;
    [loginView addSubview:_henglabel1];
    [_henglabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_icoImage.mas_bottom).offset(326/4 *AUTO_HEIGHT);
        make.left.mas_equalTo(_touImage.mas_right).offset(0);
        make.height.mas_equalTo(1 *AUTO_HEIGHT);
        make.width.mas_equalTo(loginView.frame.size.width/2);
    }];
    
    
    //手机
    _shouImage=[[UIImageView alloc]init];
    _shouImage.image=[UIImage imageNamed:@"phone"];
    [loginView addSubview:_shouImage];
    [_shouImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_touImage.mas_bottom).offset(220/4 *AUTO_HEIGHT);
        make.left.mas_equalTo(loginView).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _chlabel=[[UITextField alloc]init];
    _chlabel.delegate=self;
    _chlabel.tag=170;
    _chlabel.tintColor=GH;
   
    
    _chlabel.placeholder=@" 仅支持中国大陆手机用户";
    _chlabel.text = _chinalabel.text;
    [_chlabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _chlabel.textColor=[UIColor whiteColor];
    _chlabel.clearButtonMode=UITextFieldViewModeWhileEditing;
    _chlabel.textAlignment=NSTextAlignmentLeft;
    _chlabel.adjustsFontSizeToFitWidth=YES;
    _chlabel.keyboardType=UIKeyboardTypeNumberPad;
    _chlabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [loginView addSubview:_chlabel];
    [_chlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_touImage.mas_bottom).offset(200/4 *AUTO_WIDTH);
        make.left.equalTo(_shouImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(250 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //横线
    _label=[[UILabel alloc]init];
    _label.backgroundColor=[UIColor whiteColor];
    _label.alpha=0.6;
    [loginView addSubview:_label];
    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_shouImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(loginView.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //锁
    _lockImage=[[UIImageView alloc]init];
    _lockImage.image=[UIImage imageNamed:@"lock"];
    [loginView addSubview:_lockImage];
    [_lockImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_label.mas_bottom).offset(45/2 *AUTO_HEIGHT);
        make.left.equalTo(loginView).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _locklabel=[[UITextField alloc]init];
    _locklabel.secureTextEntry=YES;//密文输入
    _locklabel.delegate=self;
    _locklabel.tag=171;
   
    _locklabel.tintColor=GH;
    _locklabel.placeholder=@" 6-25位的字母或者数字";

    [_locklabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _locklabel.textColor=[UIColor whiteColor];
    _locklabel.textAlignment=NSTextAlignmentLeft;
    _locklabel.adjustsFontSizeToFitWidth=YES;
    _locklabel.keyboardType=UIKeyboardTypeDefault;
    _locklabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [loginView addSubview:_locklabel];
    [_locklabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_label.mas_bottom).offset(35/2 *AUTO_WIDTH);
        make.left.equalTo(_shouImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(210 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //眼睛
    _seebtn=[[UIButton alloc]init];
    [_seebtn setBackgroundImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal];
    [_seebtn setBackgroundImage:[UIImage imageNamed:@"eye1"] forState:UIControlStateSelected];
    [_seebtn addTarget:self action:@selector(seeAction:) forControlEvents:UIControlEventTouchUpInside];
    [loginView addSubview:_seebtn];
    _seebtn.tag=121;
    [_seebtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_label.mas_bottom).offset(40/2 *AUTO_WIDTH);
        make.right.equalTo(_locklabel.mas_right).offset(75/2 *AUTO_WIDTH);
        make.size.mas_offset(CGSizeMake(42/2 *AUTO_WIDTH, 42/2 *AUTO_HEIGHT));
    }];
    
    
    //横线
    _label1=[[UILabel alloc]init];
    _label1.backgroundColor=[UIColor whiteColor];
    _label1.alpha=0.6;
    [loginView addSubview:_label1];
    [_label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_lockImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(loginView.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //第四个框
    _fourView= [[UIButton alloc]init];
    _fourView.backgroundColor=GH;
    _fourView.layer.masksToBounds=YES;
    [_fourView setTitle:@"登 录" forState:UIControlStateNormal];
    [_fourView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_fourView addTarget:self action:@selector(tongAction:) forControlEvents:UIControlEventTouchUpInside];
    _fourView.titleLabel.font=[UIFont fontWithName:@"Arial" size:LOGINFONT *TEXTWEIGHT];
    [loginView addSubview:_fourView];
    [_fourView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_label1.mas_bottom).offset(285 *AUTO_HEIGHT / 4);
        make.height.mas_equalTo(84/2 *AUTO_HEIGHT);
        make.width.mas_equalTo(loginView.frame.size.width);
        
    }];
    
    
    //忘记密码
    _xiLabel= [[UILabel alloc]init];
    _xiLabel.textAlignment = NSTextAlignmentCenter;
    _xiLabel.text=@"忘记密码";
    _xiLabel.textColor=[UIColor whiteColor];
    _xiLabel.userInteractionEnabled=YES;
    UITapGestureRecognizer *xitap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(xiAction:)];
    [_xiLabel addGestureRecognizer:xitap];
    _xiLabel.font=[UIFont systemFontOfSize:13 *AUTO_WIDTH];
    [loginView addSubview:_xiLabel];
    [_xiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_fourView.mas_bottom).offset(26.00 *AUTO_HEIGHT/2);
        make.left.equalTo(loginView).offset(self.view.frame.size.width-80 *AUTO_WIDTH);
        
    }];
    
    //下划线
    _linLabel2= [[UILabel alloc]init];
    _linLabel2.backgroundColor=[UIColor whiteColor];
    [loginView addSubview:_linLabel2];
    [_linLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_xiLabel).offset(2*AUTO_HEIGHT);
        make.left.equalTo(loginView).offset(loginView.frame.size.width-80.00 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(53.00*AUTO_WIDTH, 1));
        
    }];
    
}

//注册
- (void)registAction:(UIButton *)btn {
    CATransition *transition = [CATransition animation ];
    [transition setType:@"rippleEffect"];
    [transition setDuration:0.9];
    [transition setRepeatCount:1];
    [self.view.layer addAnimation:transition forKey:@"transition"];
    regisnView = [[UIView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    [myView removeFromSuperview];
    [self.view addSubview:regisnView];
    
    
    //左侧按钮
    _button=[UIButton buttonWithType:UIButtonTypeCustom];
    [_button setImage:[UIImage imageNamed:@"fahui"] forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [regisnView addSubview:_button];
    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view.mas_top).offset(51/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(20/2 *AUTO_WIDTH);
    }];
    
    
    
    self.ioImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fan"]];
    [regisnView addSubview:_ioImage];
    self.ioImage.userInteractionEnabled = YES;
    [self.ioImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.top.mas_equalTo(self.view).offset(260/2 *AUTO_HEIGHT);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(350/2 *AUTO_WIDTH, 92/2 *AUTO_HEIGHT));
        
    }];
    
    
    //手机
    _shImage=[[UIImageView alloc]init];
    _shImage.image=[UIImage imageNamed:@"phone"];
    [regisnView addSubview:_shImage];
    [_shImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.view).offset(509/2 *AUTO_HEIGHT);
        make.left.mas_equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _chinalabel=[[UITextField alloc]init];
    _chinalabel.delegate=self;
    _chinalabel.tag=180;
    _chinalabel.tintColor=GH;
    _chinalabel.placeholder=@" 仅支持中国大陆手机用户";
    [_chinalabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _chinalabel.textColor=[UIColor whiteColor];
    _chinalabel.clearButtonMode=UITextFieldViewModeWhileEditing;
    _chinalabel.textAlignment=NSTextAlignmentLeft;
    _chinalabel.keyboardType=UIKeyboardTypeNumberPad;
    _chinalabel.adjustsFontSizeToFitWidth=YES;
    _chinalabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [regisnView addSubview:_chinalabel];
    [_chinalabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).offset(500/2 *AUTO_WIDTH);
        make.left.equalTo(_shImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(250 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //横线
    _rank=[[UILabel alloc]init];
    _rank.backgroundColor=[UIColor whiteColor];
    _rank.alpha=0.6;
    [regisnView addSubview:_rank];
    [_rank mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_shImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    //锁
    _lckImage=[[UIImageView alloc]init];
    _lckImage.image=[UIImage imageNamed:@"lock"];
    [regisnView addSubview:_lckImage];
    [_lckImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(45/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _lcklabel=[[UITextField alloc]init];
    _lcklabel.secureTextEntry=YES;//密文输入
    _lcklabel.delegate=self;
    _lcklabel.tag=181;
    _lcklabel.tintColor=GH;
    _lcklabel.placeholder=@" 6-25位的字母或者数字";
    [_lcklabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _lcklabel.textColor=[UIColor whiteColor];
    _lcklabel.textAlignment=NSTextAlignmentLeft;
    _lcklabel.adjustsFontSizeToFitWidth=YES;
    _lcklabel.keyboardType=UIKeyboardTypeDefault;
    _lcklabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [regisnView addSubview:_lcklabel];
    [_lcklabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(35/2 *AUTO_WIDTH);
        make.left.equalTo(_shImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(210 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //眼睛
    _see=[[UIButton alloc]init];
    [_see setBackgroundImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal];
    [_see setBackgroundImage:[UIImage imageNamed:@"eye1"] forState:UIControlStateSelected];
    [_see addTarget:self action:@selector(seeAction:) forControlEvents:UIControlEventTouchUpInside];
    _see.tag=120;
    [regisnView addSubview:_see];
    [_see mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(40/2 *AUTO_WIDTH);
        make.right.equalTo(_lcklabel.mas_right).offset(75/2 *AUTO_WIDTH);
        make.size.mas_offset(CGSizeMake(42/2 *AUTO_WIDTH, 42/2 *AUTO_HEIGHT));
    }];
    
    //横线
    _rank1=[[UILabel alloc]init];
    _rank1.backgroundColor=[UIColor whiteColor];
    _rank1.alpha=0.6;
    [regisnView addSubview:_rank1];
    [_rank1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_lckImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //手机
    _phoneImage=[[UIImageView alloc]init];
    _phoneImage.image=[UIImage imageNamed:@"phone1"];
    [regisnView addSubview:_phoneImage];
    [_phoneImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(45/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //验证码
    _codelabel=[[UITextField alloc]init];
    _codelabel.delegate=self;
    _codelabel.tag=182;
    _codelabel.tintColor=GH;
    _codelabel.placeholder=@" 验证码";
    [_codelabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _codelabel.textColor=[UIColor whiteColor];
    _codelabel.textAlignment=NSTextAlignmentLeft;
    _codelabel.adjustsFontSizeToFitWidth=YES;
    _codelabel.keyboardType=UIKeyboardTypeNumberPad;
    _codelabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [regisnView addSubview:_codelabel];
    [_codelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(35/2 *AUTO_WIDTH);
        make.left.equalTo(_phoneImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(210 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //获取验证码
    _huolabel= [UIButton buttonWithType:UIButtonTypeCustom];
    [_huolabel addTarget:self action:@selector(sendMessage:) forControlEvents:UIControlEventTouchUpInside];
    [_huolabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_huolabel setTitle:@"获取验证码" forState:UIControlStateNormal];
    _huolabel.titleLabel.font= [UIFont systemFontOfSize:9.00 *AUTO_WIDTH];
    _huolabel.layer.masksToBounds = YES;
    _huolabel.layer.cornerRadius = 22.00*AUTO_WIDTH/2;
    _huolabel.layer.borderColor = [[UIColor whiteColor]CGColor];
    _huolabel.layer.borderWidth = 1.0;
    [regisnView addSubview:_huolabel];
    [_huolabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(45 * AUTO_HEIGHT/2);
        make.right.equalTo(self.view).offset(-76*AUTO_WIDTH/2);
        make.width.mas_equalTo(107.00 *AUTO_WIDTH/2);
        
    }];
    
    //横线
    _rank2=[[UILabel alloc]init];
    _rank2.backgroundColor=[UIColor whiteColor];
    _rank2.alpha=0.6;
    [regisnView addSubview:_rank2];
    [_rank2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_phoneImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //接收验证码
    _longLabel= [[UILabel alloc]init];
    _longLabel.textAlignment = NSTextAlignmentCenter;
    _longLabel.text=@"长时间收不到验证码，可尝试";
    _longLabel.textColor=[UIColor whiteColor];
    _longLabel.font=[UIFont systemFontOfSize:13.00 * AUTO_WIDTH];
    [regisnView addSubview:_longLabel];
    [_longLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_rank2).offset(55.00 *AUTO_HEIGHT / 2 + 20);
        make.left.equalTo(self.view).offset(184/4 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-184/4 *AUTO_WIDTH);
        
    }];
    
    
    //语音接听
    _yuLabel= [[UILabel alloc]init];
    _yuLabel.textAlignment = NSTextAlignmentCenter;
    _yuLabel.textColor=GH;
    _yuLabel.text=@"语音接听验证码";
    _yuLabel.font=[UIFont systemFontOfSize:13.00 *AUTO_WIDTH];
    [regisnView addSubview:_yuLabel];
    [_yuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_longLabel.mas_bottom).offset(10.00 *AUTO_HEIGHT / 2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 60.00*AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 60.00 *AUTO_WIDTH));
        
    }];
    
    
    //下划线
    _lineLabel= [[UILabel alloc]init];
    _lineLabel.backgroundColor=GH;
    [regisnView addSubview:_lineLabel];
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_yuLabel).offset(2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 44.00 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 44.00 * AUTO_WIDTH));
        make.height.mas_equalTo(1);
        
    }];
    
    
    //第四个框
    _fouView= [[UIButton alloc]init];
    _fouView.backgroundColor=GH;
    _fouView.layer.masksToBounds=YES;
    [_fouView setTitle:@"同意协议并注册" forState:UIControlStateNormal];
    [_fouView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_fouView addTarget:self action:@selector(tongActionZhuce:) forControlEvents:UIControlEventTouchUpInside];
    _fouView.titleLabel.font=[UIFont fontWithName:@"Arial" size:LOGINFONT *TEXTWEIGHT];
    [regisnView addSubview:_fouView];
    [_fouView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_yuLabel.mas_bottom).offset(67.00 *AUTO_HEIGHT / 2);
        make.height.mas_equalTo(84/2 *AUTO_HEIGHT);
        make.width.mas_equalTo(self.view.frame.size.width);
        
    }];
    
    
    //注册协议
    _xieLabel= [[UILabel alloc]init];
    _xieLabel.textAlignment = NSTextAlignmentCenter;
    _xieLabel.text=@"注册协议" ;
    _xieLabel.textColor=[UIColor whiteColor];
    UITapGestureRecognizer *resignDelegate = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(registerDelegate)];
    _xieLabel.userInteractionEnabled = YES;
    [_xieLabel addGestureRecognizer:resignDelegate];
    _xieLabel.font=[UIFont systemFontOfSize:13 *AUTO_WIDTH];
    [regisnView addSubview:_xieLabel];
    [_xieLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_fouView.mas_bottom).offset(34.00 *AUTO_HEIGHT/2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 60.00 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 60.00 *AUTO_WIDTH));
        
    }];
    
    
    //下划线
    _lineLabel2= [[UILabel alloc]init];
    _lineLabel2.backgroundColor=[UIColor whiteColor];
    [regisnView addSubview:_lineLabel2];
    [_lineLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_xieLabel).offset(2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 24.00 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 24.00 *AUTO_WIDTH));
        make.height.mas_equalTo(1);
        
    }];
    
}
//注册协议
-(void)registerDelegate{
    
    PXGafaerProtocolViewController *protocolController = [[PXGafaerProtocolViewController alloc] init];
    protocolController.webStr = GAFAERPROTOCOL;
    protocolController.navigationItem.title = @"注册协议";
    [self.navigationController pushViewController:protocolController animated:YES];
    
    
}
-(void) xiAction:( UITapGestureRecognizer *) tap
{
    [self.collectionView removeFromSuperview];
    self.pageControl.alpha=0;
    self.loginBtn.alpha=0;
    self.registBtn.alpha=0;
    self.icoImage.alpha=0;
    self.bttn.alpha=0;
    self.icImage.alpha=0;
    self.henglabel.alpha=0;
    self.touImage.alpha=0;
    self.fourView.alpha=0;
    self.henglabel1.alpha=0;
    self.shouImage.alpha=0;
    self.chlabel.alpha=0;
    self.label.alpha=0;
    self.lockImage.alpha=0;
    self.locklabel.alpha=0;
    self.seebtn.alpha=0;
    self.label1.alpha=0;
    self.xiLabel.alpha=0;
    self.linLabel2.alpha=0;
    
    
    
    //左侧按钮
    _button=[UIButton buttonWithType:UIButtonTypeCustom];
    [_button setImage:[UIImage imageNamed:@"fahui"] forState:UIControlStateNormal];
    [_button addTarget:self action:@selector(buttAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_button];
    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view.mas_top).offset(51/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(20/2 *AUTO_WIDTH);
    }];
    
    
    
    self.ioImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fan"]];
    [self.view addSubview:_ioImage];
    self.ioImage.userInteractionEnabled = YES;
    [self.ioImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.top.mas_equalTo(self.view).offset(260/2 *AUTO_HEIGHT);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(350/2 *AUTO_WIDTH, 92/2 *AUTO_HEIGHT));
        
    }];
    
    
    //手机
    _shImage=[[UIImageView alloc]init];
    _shImage.image=[UIImage imageNamed:@"phone"];
    [self.view addSubview:_shImage];
    [_shImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.view).offset(509/2 *AUTO_HEIGHT);
        make.left.mas_equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _chinalabel=[[UITextField alloc]init];
    _chinalabel.delegate=self;
    _chinalabel.tag=170;
    _chinalabel.tintColor=GH;
    _chinalabel.placeholder=@" 仅支持中国大陆手机用户";
    [_chinalabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _chinalabel.textColor=[UIColor whiteColor];
    _chinalabel.clearButtonMode=UITextFieldViewModeWhileEditing;
    _chinalabel.textAlignment=NSTextAlignmentLeft;
    _chinalabel.keyboardType=UIKeyboardTypeNumberPad;
    _chinalabel.adjustsFontSizeToFitWidth=YES;
    _chinalabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [self.view addSubview:_chinalabel];
    [_chinalabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.view).offset(500/2 *AUTO_WIDTH);
        make.left.equalTo(_shImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(250 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //横线
    _rank=[[UILabel alloc]init];
    _rank.backgroundColor=[UIColor whiteColor];
    _rank.alpha=0.6;
    [self.view addSubview:_rank];
    [_rank mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_shImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    //锁
    _lckImage=[[UIImageView alloc]init];
    _lckImage.image=[UIImage imageNamed:@"lock"];
    [self.view addSubview:_lckImage];
    [_lckImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(45/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //仅支持中国大陆手机用户
    _lcklabel=[[UITextField alloc]init];
    _lcklabel.secureTextEntry=YES;//密文输入
    _lcklabel.delegate=self;
    _lcklabel.tag=172;
    _lcklabel.tintColor=GH;
    _lcklabel.placeholder=@" 6-25位的字母或者数字";
    [_lcklabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _lcklabel.textColor=[UIColor whiteColor];
    _lcklabel.textAlignment=NSTextAlignmentLeft;
    _lcklabel.adjustsFontSizeToFitWidth=YES;
    _lcklabel.keyboardType=UIKeyboardTypeDefault;
    _lcklabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [self.view addSubview:_lcklabel];
    [_lcklabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(35/2 *AUTO_WIDTH);
        make.left.equalTo(_shImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(210 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //眼睛
    _see=[[UIButton alloc]init];
    [_see setBackgroundImage:[UIImage imageNamed:@"eye"] forState:UIControlStateNormal];
    [_see setBackgroundImage:[UIImage imageNamed:@"eye1"] forState:UIControlStateSelected];
    _see.tag=120;
    [_see addTarget:self action:@selector(seeAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_see];
    [_see mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank.mas_bottom).offset(40/2 *AUTO_WIDTH);
        make.right.equalTo(_lcklabel.mas_right).offset(75/2 *AUTO_WIDTH);
        make.size.mas_offset(CGSizeMake(42/2 *AUTO_WIDTH, 42/2 *AUTO_HEIGHT));
    }];
    
    //横线
    _rank1=[[UILabel alloc]init];
    _rank1.backgroundColor=[UIColor whiteColor];
    _rank1.alpha=0.6;
    [self.view addSubview:_rank1];
    [_rank1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_lckImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //手机
    _phoneImage=[[UIImageView alloc]init];
    _phoneImage.image=[UIImage imageNamed:@"phone1"];
    [self.view addSubview:_phoneImage];
    [_phoneImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(45/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(87/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(45/2 *AUTO_WIDTH, 45/2 *AUTO_HEIGHT));
    }];
    
    
    //验证码
    _codelabel=[[UITextField alloc]init];
    _codelabel.delegate=self;
    _codelabel.tag=170;
    _codelabel.tintColor=GH;
    _codelabel.placeholder=@" 验证码";
    [_codelabel setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    _codelabel.textColor=[UIColor whiteColor];
    _codelabel.textAlignment=NSTextAlignmentLeft;
    _codelabel.adjustsFontSizeToFitWidth=YES;
    _codelabel.keyboardType=UIKeyboardTypeNumberPad;
    _codelabel.font=[UIFont systemFontOfSize:14.00 *AUTO_WIDTH];
    [self.view addSubview:_codelabel];
    [_codelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(35/2 *AUTO_WIDTH);
        make.left.equalTo(_phoneImage.mas_left).offset(98/2*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(210 *AUTO_WIDTH, 32*AUTO_HEIGHT));
    }];
    
    
    //获取验证码
    _huolabel= [UIButton buttonWithType:UIButtonTypeCustom];
    [_huolabel addTarget:self action:@selector(sendMessage:) forControlEvents:UIControlEventTouchUpInside];
    [_huolabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_huolabel setTitle:@"获取验证码" forState:UIControlStateNormal];
    _huolabel.titleLabel.font= [UIFont systemFontOfSize:9.00 *AUTO_WIDTH];
    _huolabel.layer.masksToBounds = YES;
    _huolabel.layer.cornerRadius = 22.00*AUTO_WIDTH/2;
    _huolabel.layer.borderColor = [[UIColor whiteColor]CGColor];
    _huolabel.layer.borderWidth = 1.0;
    [self.view addSubview:_huolabel];
    [_huolabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_rank1.mas_bottom).offset(45 * AUTO_HEIGHT/2);
        make.right.equalTo(self.view).offset(-76*AUTO_WIDTH/2);
        make.width.mas_equalTo(107.00 *AUTO_WIDTH/2);
        
    }];
    
    //横线
    _rank2=[[UILabel alloc]init];
    _rank2.backgroundColor=[UIColor whiteColor];
    _rank2.alpha=0.6;
    [self.view addSubview:_rank2];
    [_rank2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_phoneImage.mas_bottom).offset(40/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1 *AUTO_HEIGHT));
    }];
    
    
    //接收验证码
    _longLabel= [[UILabel alloc]init];
    _longLabel.textAlignment = NSTextAlignmentCenter;
    _longLabel.text=@"长时间收不到验证码，可尝试";
    _longLabel.textColor=[UIColor whiteColor];
    _longLabel.font=[UIFont systemFontOfSize:13.00 * AUTO_WIDTH];
    [self.view addSubview:_longLabel];
    [_longLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_rank2).offset(55.00 *AUTO_HEIGHT / 2 + 20);
        make.left.equalTo(self.view).offset(184/4 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-184/4 *AUTO_WIDTH);
        
    }];
    
    
    //语音接听
    _yuLabel= [[UILabel alloc]init];
    _yuLabel.textAlignment = NSTextAlignmentCenter;
    _yuLabel.textColor=GH;
    _yuLabel.text=@"语音接听验证码";
    _yuLabel.font=[UIFont systemFontOfSize:13.00 *AUTO_WIDTH];
    [self.view addSubview:_yuLabel];
    [_yuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_longLabel.mas_bottom).offset(10.00 *AUTO_HEIGHT / 2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 60.00*AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 60.00 *AUTO_WIDTH));
        
    }];
    
    
    //下划线
    _lineLabel= [[UILabel alloc]init];
    _lineLabel.backgroundColor=GH;
    [self.view addSubview:_lineLabel];
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(_yuLabel).offset(2);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2 - 42.00 *AUTO_WIDTH);
        make.right.equalTo(self.view).offset(-(self.view.frame.size.width/2 - 42.00 * AUTO_WIDTH));
        make.height.mas_equalTo(1);
        
    }];
    
    
    //第四个框
    _fouView= [[UIButton alloc]init];
    _fouView.backgroundColor=GH;
    _fouView.layer.masksToBounds=YES;
    
    [_fouView setTitle:@"重置密码" forState:UIControlStateNormal];
    [_fouView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_fouView addTarget:self action:@selector(tongAction:) forControlEvents:UIControlEventTouchUpInside];
    _fouView.titleLabel.font=[UIFont fontWithName:@"Arial" size:LOGINFONT *TEXTWEIGHT];
    [self.view addSubview:_fouView];
    [_fouView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_yuLabel.mas_bottom).offset(67.00 *AUTO_HEIGHT / 2);
        make.height.mas_equalTo(84/2 *AUTO_HEIGHT);
        make.width.mas_equalTo(self.view.frame.size.width);
        
    }];
    
    
}



#pragma mark - collectionView delegate && dataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    MainCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.contentLabel.text=[_titleArray objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    
    self.pageControl.currentPage = scrollView.contentOffset.x / SCREEN_WIDTH;
}


#pragma mark - 视频播放通知
- (void)addNotification{
    //给AVPlayerItem添加播放完成通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem];
}

- (void)removeNotification{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
/**
 *  播放完成通知
 *
 *  @param notification 通知对象
 */
-(void)playbackFinished:(NSNotification *)notification{
    NSLog(@"视频播放完成.");
    
    
    // 播放完成后重复播放
    // 跳到最新的时间点开始播放
    [_player seekToTime:CMTimeMake(0, 1)];
    [_player play];
}


#pragma mark - 登入
- (void)tongAction:(UIButton *)btu{
    

  
    
    [self getLogInMessage];

    
    NSArray *phone = [_chinalabel.text componentsSeparatedByString:@"-"];
    phoneNumber = [NSString string];
    for (NSString *str in phone) {
        phoneNumber = [phoneNumber stringByAppendingString:str];
    }

    
  
    
}
-(void)getLogInMessage{
    NSLog(@"-------=%@",phoneNumber);
    NSLog(@"========%@",_lcklabel.text);
    NSLog(@",,,,,,,,%@",_chlabel.text);
    NSLog(@"........%@",_locklabel.text);
    NSArray *phoneArray = [_chlabel.text componentsSeparatedByString:@"-"];
    loginNumber = [NSString string];
    for (NSString *str in phoneArray) {
        
        loginNumber = [loginNumber stringByAppendingString:str];
    }
    
    [paramars setObject:[LOCALSEVE objectForKey:@"UID"] forKey:@"uid"];
    [paramars setObject:[LOCALSEVE objectForKey:@"MCODE"] forKey:@"mcode"];
    
    [paramars setObject:loginNumber forKey:@"uphone"];
    [paramars setObject:_locklabel.text forKey:@"uspawd"];
    NSString * url_string = [NSString stringWithFormat:@"%@%@",JIAFANURL,@"Gafaer/User/login/"];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = HTTPSET;
    [manager GET:url_string parameters:paramars success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSLog(@".............%@",responseObject);
        if ([[[responseObject objectForKey:@"data" ] objectForKey:@"sortid"] isEqualToString:@"0"]) {
            [[NSUserDefaults standardUserDefaults ] setObject:[[responseObject objectForKey:@"data" ] objectForKey:@"uid"] forKey:@"UID"];
            [[NSUserDefaults standardUserDefaults ] setObject:[[responseObject objectForKey:@"data" ] objectForKey:@"mcode"] forKey:@"MCODE"];
            
            AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
            
            self.view.window.rootViewController = delegate.ntabbar;
            
        }
        
        else if ([[[responseObject objectForKey:@"data" ] objectForKey:@"sortid"] isEqualToString:@"1"]){
        

            // YHYDesigneViewsViewController
            //
            //    //    [delegate goMainViewController];
                AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

            [[NSUserDefaults standardUserDefaults ] setObject:[[responseObject objectForKey:@"data" ] objectForKey:@"uid"] forKey:@"UID"];
            [[NSUserDefaults standardUserDefaults ] setObject:[[responseObject objectForKey:@"data" ] objectForKey:@"mcode"] forKey:@"MCODE"];
            

            
          
                self.view.window.rootViewController = delegate.stabbar;
        
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@",,,,,,,,,,,,%@",error);
        
    }];
    
    
}

#pragma mark - 注册成功 跳到 寻找设计师和我是设计师
//注册成功后
-(void) tongActionZhuce:(UIButton *) btn
{

    NSArray *phoneArray = [_chinalabel.text componentsSeparatedByString:@"-"];
    phoneNumber = [NSString string];
    for (NSString *str in phoneArray) {
        
        phoneNumber = [phoneNumber stringByAppendingString:str];
    }
    NSLog(@"-------=%@",phoneNumber);
    NSLog(@"========%@",_lcklabel.text);
    [self postHpone:phoneNumber :_lcklabel.text];
    
    [self alertViewShow];
    
    
}

-(void)alertViewShow{
    
    if (_chinalabel.text.length == 0) {
        NSLog(@"数据不能为空");
        
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"" message:@"家范儿提示\n\n    手机号不可以为空哦！" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alertC animated:YES completion:^{
            NSLog(@"iiii");
            
            [UIView animateWithDuration:4 animations:^{
                
                [alertC dismissViewControllerAnimated:YES completion:^{
                    
                    
                }];
                
            }];
            
        }];
    }
    if (_lcklabel.text.length == 0) {
        NSLog(@"数据不能为空");
        
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"" message:@"家范儿提示\n\n    密码不可以为空哦！" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alertC animated:YES completion:^{
            NSLog(@"iiii");
            
            [UIView animateWithDuration:4 animations:^{
                
                [alertC dismissViewControllerAnimated:YES completion:^{
                    
                    
                }];
                
            }];
            
        }];
        
    }
    if (_codelabel.text.length == 0) {
        NSLog(@"数据不能为空");
        
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"" message:@"家范儿提示\n\n    验证码不可以为空哦！" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alertC animated:YES completion:^{
            NSLog(@"iiii");
            
            [UIView animateWithDuration:4 animations:^{
                
                [alertC dismissViewControllerAnimated:YES completion:^{
                    
                    
                }];
                
            }];
            
        }];
        
    }
    
    
    
    
    //    self.view.window.rootViewController = user;
}



-(void)postHpone:(NSString *) phoneNumber:(NSString *)password{
    
    UserTypeViewController *user=[[UserTypeViewController alloc]init];
    //    NSString *url_string = [NSString stringWithFormat:@"http://120.55.68.35/v1/Soeasn/User/reg/"];
    NSString *url = [NSString stringWithFormat:@"Gafaer/User/reg/"];
    NSString * url_string = [NSString stringWithFormat:@"%@%@",JIAFANURL,url];
//    [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  //代表支持所有的接口类型
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    NSLog(@"qqqq=%@,%@",_chlabel.text,_locklabel);
    NSDictionary *dic = @{@"uphone":phoneNumber,@"uspawd":password};
    [manager POST:url_string parameters: dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        user.code = [[responseObject objectForKey:@"data"] objectForKey:@"mcode"];
        user.uid = [[responseObject objectForKey:@"data"] objectForKey:@"uid"];
        [[NSUserDefaults standardUserDefaults] setObject:[[responseObject objectForKey:@"data"]objectForKey:@"uid"] forKey:@"UID"];
        [[NSUserDefaults standardUserDefaults] setObject:[[responseObject objectForKey:@"data"]objectForKey:@"mcode"] forKey:@"MCODE"];
        
        NSLog(@"iii=%@",responseObject);
        
        if ([[responseObject objectForKey:@"code"] isEqualToString:@"200"]) {
            
            [self.navigationController pushViewController:user animated:YES];
        }
        
        if ([[responseObject objectForKey:@"code"] isEqualToString:@"403"]) {
            UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"" message:@"家范儿提示\n\n    您已经注册过了！" preferredStyle:UIAlertControllerStyleAlert];
            
            [self presentViewController:alertC animated:YES completion:^{
                NSLog(@"iiii");
                
                [UIView animateWithDuration:4 animations:^{
                    
                    [alertC dismissViewControllerAnimated:YES completion:^{
                        _locklabel.text = phoneNumber;
                        
                    }];
                    
                }];
                
            }];

        }

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"error=%@",error);
        
    }];
    

}

// 设置textField的长度
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    
    if (textField ==_chlabel) {
        
        if (textField.tag == 180 || textField.tag == 170) {
            NSString *text = [textField text];
            NSLog(@"----%@",text);
            NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
            string = [string stringByReplacingOccurrencesOfString:@"-" withString:@""];
            if ([string rangeOfCharacterFromSet:[characterSet invertedSet]].location != NSNotFound) {
                return NO;
            }
            text = [text stringByReplacingCharactersInRange:range withString:string];
            text = [text stringByReplacingOccurrencesOfString:@"-" withString:@""];
            NSString *newString = @"";
            while (text.length > 0) {
                if (newString.length == 0) {
                    NSString *subString = [text substringToIndex:MIN(text.length, 3)];
                    newString = [newString stringByAppendingString:subString];
                    if (subString.length == 3) {
                        newString = [newString stringByAppendingString:@"-"];
                    }
                    text = [text substringFromIndex:MIN(text.length, 3)];
                } else {
                    NSString *subString = [text substringToIndex:MIN(text.length, 4)];
                    newString = [newString stringByAppendingString:subString];
                    if (subString.length == 4) {
                        newString = [newString stringByAppendingString:@"-"];
                    }
                    text = [text substringFromIndex:MIN(text.length, 4)];
                }
            }
            newString = [newString stringByTrimmingCharactersInSet:[characterSet invertedSet]];
            
            if (newString.length >= 15) {
                return NO;
            }
            
            [textField setText:newString];
            NSLog(@"111111=%@",newString);
            return NO;
            
        } else {
            
            NSString *text = [textField text];
            NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789_QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"];
            if ([string rangeOfCharacterFromSet:[characterSet invertedSet]].location != NSNotFound) {
                return NO;
            }
            if (text.length >= 25) {
                return YES;
            }
            text = [text stringByReplacingCharactersInRange:range withString:string];
            [textField setText:text];
            return NO;
            
        }
        
        
    }
    if (textField ==_lcklabel) {
        
        if (textField.text.length <=25) {
            
            if (range.location ==25) {
                
                return NO;
            }else if (range.location ==0){
                
                NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
                
                if (range.location != NSNotFound) {
                    
                }else{
                    
                    
                    textField.text=str;
                }
                return YES;
            }else if (range.location ==0){
                
                NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
                NSString *str1;
                str1=[str stringByReplacingOccurrencesOfString:@"-" withString:@""];
                textField.text=str1;
                return YES;
            }else {
                
                return YES;
                
            }
            return NO;
        }
        
        
    }
    if (textField == _codelabel) {
        
        
        if (range.location ==4) {
            
            return NO;
        }else if (range.location ==8){
            
            
            
            NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
            
            if (range.location != NSNotFound) {
                
            }else{
                
                
                textField.text=str;
            }
            return YES;
        }else if (range.location ==9){
            
            NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
            NSString *str1;
            str1=[str stringByReplacingOccurrencesOfString:@"-" withString:@""];
            textField.text=str1;
            return YES;
        }else {
            
            return YES;
        }
        
        
    }
    
    if (textField ==_chinalabel) {
        
        if (textField.tag == 180) {
            NSString *text = [textField text];
            NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
            string = [string stringByReplacingOccurrencesOfString:@"-" withString:@""];
            if ([string rangeOfCharacterFromSet:[characterSet invertedSet]].location != NSNotFound) {
                return NO;
            }
            text = [text stringByReplacingCharactersInRange:range withString:string];
            text = [text stringByReplacingOccurrencesOfString:@"-" withString:@""];
            NSString *newString = @"";
            while (text.length > 0) {
                if (newString.length == 0) {
                    NSString *subString = [text substringToIndex:MIN(text.length, 3)];
                    newString = [newString stringByAppendingString:subString];
                    if (subString.length == 3) {
                        newString = [newString stringByAppendingString:@"-"];
                    }
                    text = [text substringFromIndex:MIN(text.length, 3)];
                } else {
                    NSString *subString = [text substringToIndex:MIN(text.length, 4)];
                    newString = [newString stringByAppendingString:subString];
                    if (subString.length == 4) {
                        newString = [newString stringByAppendingString:@"-"];
                    }
                    text = [text substringFromIndex:MIN(text.length, 4)];
                }
            }
            newString = [newString stringByTrimmingCharactersInSet:[characterSet invertedSet]];
            
            if (newString.length >= 15) {
                return NO;
            }
            
            [textField setText:newString];
            NSLog(@"999999=%@",newString);
            return NO;
            
        } else {
            
            NSString *text = [textField text];
            NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789_QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"];
            if ([string rangeOfCharacterFromSet:[characterSet invertedSet]].location != NSNotFound) {
                return NO;
            }
            if (text.length >= 25) {
                return YES;
            }
            text = [text stringByReplacingCharactersInRange:range withString:string];
            [textField setText:text];
            return NO;
            
        }
        
        
    }
    
    if (textField ==_locklabel) {
        
        if (textField.text.length <=25) {
            
            if (range.location ==25) {
                
                return NO;
            }else if (range.location ==0){
                
                NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
                
                if (range.location != NSNotFound) {
                    
                }else{
                    
                    
                    textField.text=str;
                }
                return YES;
            }else if (range.location ==0){
                
                NSMutableString *str=[[NSMutableString alloc]initWithString:textField.text];
                NSString *str1;
                str1=[str stringByReplacingOccurrencesOfString:@"-" withString:@""];
                textField.text=str1;
                return YES;
            }else {
                
                return YES;
                
            }
            return NO;
        }
        
        
    }
    
    return NO;
    
}

//获取验证码
-(void) sendMessage:(UIButton *) btn
{
    if (_chlabel.text.length !=11) {
        
        _timeNum=60;
        _getTime=[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerFired) userInfo:nil repeats:YES];
        _huolabel.enabled=NO;
        [_huolabel setTitle:@"60S" forState:UIControlStateDisabled];
    }
}

//timerFired
-(void) timerFired
{
    if (_timeNum >0) {
        _timeNum--;
        _huolabel.enabled=NO;
        [_huolabel setTitle:[NSString stringWithFormat:@"%ldS",(long)_timeNum] forState:UIControlStateDisabled];
    }else{
        
        if ([_getTime isValid]) {
            [_getTime invalidate];
            _getTime =nil;
        }
        _huolabel.enabled=YES;
        [_huolabel setTitle:@"重新获取" forState:UIControlStateNormal];
    }
}


//眼睛按钮
-(void) seeAction:(UIButton *) btn
{
    if (btn.tag ==120) {
        btn.selected =!btn.selected;
        if (btn.selected ==YES) {
            _lcklabel.secureTextEntry=NO;
        }else{
            
            _lcklabel.secureTextEntry=YES;
        }
        
    }
    
    if (btn.tag ==121) {
        btn.selected =!btn.selected;
        if (btn.selected ==YES) {
            _locklabel.secureTextEntry=NO;
        }else{
            
            _locklabel.secureTextEntry=YES;
        }
        
    }
    
}


-(void) btnAction:(UIButton *) btn

{
    
 
    
}

-(void) buttonAction:(UIButton *) btn
{
    CATransition *transition = [CATransition animation ];
    [transition setType:@"rippleEffect"];
    [transition setDuration:1];
    [transition setRepeatCount:1];
    [self.view.layer addAnimation:transition forKey:@"transition"];
    myView.frame = [[UIScreen mainScreen]bounds];
    [self.view addSubview:myView];
    [loginView removeFromSuperview];
    [regisnView removeFromSuperview];
    
}

-(void) buttAction: (UIButton *) btn
{
   
}


-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{

    NSTimeInterval animationDuration=0.30f;
    [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
    [UIView setAnimationDuration:animationDuration];
    float width = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    //上移n个单位，按实际情况设置
    CGRect rect=CGRectMake(0.0f,-200,width,height);
    self.view.frame=rect;
    [UIView commitAnimations];
    return YES;
}

-(void) userAction:(UITapGestureRecognizer *)  tap
{
    [_chinalabel resignFirstResponder];
    [_chlabel resignFirstResponder];
    [_locklabel resignFirstResponder];
    [_lcklabel resignFirstResponder];
    [_codelabel resignFirstResponder];
    
    [UIView animateWithDuration:0.20f animations:^{
        
        
        self.view.frame =CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        
    }];
}






@end
